﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

#if XNA || WINDOWS_PHONE
using Microsoft.Xna.Framework;
#endif

namespace XELF.Framework {

	public partial struct Matrix {
		/// <summary>
		/// 和
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Add(ref Matrix a, ref Matrix b, out Matrix result) {
			result = new Matrix(
				a.M11 + b.M11, a.M12 + b.M12, a.M13 + b.M13, a.M14 + b.M14,
				a.M21 + b.M21, a.M22 + b.M22, a.M23 + b.M23, a.M24 + b.M24,
				a.M31 + b.M31, a.M32 + b.M32, a.M33 + b.M33, a.M34 + b.M34,
				a.M41 + b.M41, a.M42 + b.M42, a.M43 + b.M43, a.M44 + b.M44);
		}
		/// <summary>
		/// 和
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		public static Matrix Add(Matrix a, Matrix b) {
			Matrix result;
			Add(ref a, ref b, out result);
			return result;
		}

		/// <summary>
		/// 差
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Subtract(ref Matrix a, ref Matrix b, out Matrix result) {
			result = new Matrix(
				a.M11 - b.M11, a.M12 - b.M12, a.M13 - b.M13, a.M14 - b.M14,
				a.M21 - b.M21, a.M22 - b.M22, a.M23 - b.M23, a.M24 - b.M24,
				a.M31 - b.M31, a.M32 - b.M32, a.M33 - b.M33, a.M34 - b.M34,
				a.M41 - b.M41, a.M42 - b.M42, a.M43 - b.M43, a.M44 - b.M44);
		}
		/// <summary>
		/// 差
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		public static Matrix Subtract(Matrix a, Matrix b) {
			Matrix result;
			Subtract(ref a, ref b, out result);
			return result;
		}
	}

}
